﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Ninject;
using System.Web.Mvc;
using Nutrapp.DBAL;
using Moq;
using Nutrapp.Infrastructure.Abstract;
using Nutrapp.Infrastructure.Concrete;


namespace Nutrapp.Infrastructure
{
    public class NinjectDependencyResolver : IDependencyResolver
    {
        private IKernel kernel;
        public NinjectDependencyResolver(IKernel kernelParam)
        {
            kernel = kernelParam;
            AddBindings();
        }

        public object GetService(Type serviceType)
        {
            return kernel.TryGet(serviceType);
        }

        public IEnumerable<object> GetServices(Type serviceType)
        {
            return kernel.GetAll(serviceType);
        }

        private void AddBindings()
        {
            kernel.Bind<IRecipeRepository>().To<DBRecipeRepository>();
            kernel.Bind<IIngredientRepository>().To<DBIngredientRepository>();
            kernel.Bind<IUnitRepository>().To<DBUnitRepository>();
            kernel.Bind<IAuthProvider>().To<FormsAuthProvider>();
            kernel.Bind<IRecipe_Ingredient_Repository>().To<DBRecipe_Ingredient_Repository>();
        }
    }
}